use serde::{Deserialize, Serialize};

use common::page::{BasePage, PageData};

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CreateDictGroup {
    pub group_name: Option<String>,
    pub group_code: Option<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct DictGroupPage {
    pub page_data: Option<PageData>,
    pub group_name: Option<String>,
    pub group_code: Option<String>,
}

impl BasePage for DictGroupPage {
    fn get_page_data(&self) -> PageData {
        match self.page_data.clone() {
            None => {
                PageData{
                    page: 1,
                    page_size: 10,
                    sorter: None,
                }
            }
            Some(page_data) => {
                page_data
            }
        }
    }
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CreateDict {
    pub parent_id: Option<i64>,
    pub name: Option<String>,
    pub code: Option<String>,
    pub value: Option<String>,
    pub group_id: Option<i64>,
    pub default: Option<bool>,
    pub dict_desc: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct DictPage {
    pub page_data: Option<PageData>,
    pub parent_id: Option<i64>,
    pub name: Option<String>,
    pub code: Option<String>,
    pub group_id: Option<i64>,
    pub default: Option<bool>,
    pub dict_desc: Option<String>,
}

impl BasePage for DictPage {
    fn get_page_data(&self) -> PageData {
        match self.page_data.clone() {
            None => {
                PageData{
                    page: 1,
                    page_size: 10,
                    sorter: None,
                }
            }
            Some(page_data) => {
                page_data
            }
        }
    }
}
